/// 网易易盾一键登录iOS自定义页面的自定义控件对应模型
class IosWidgetModel {
  /// 控件类型，可选值为 UILabel、UIButton
  String? type;

  /// UIButton显示的图片。内容为图片名，不需要加图片后缀
  String? image;

  /// UIButton显示的文字
  String? title;

  /// UIButton显示的字体颜色
  String? titleColor;

  /// 字体的大小
  double? titleFont;

  /// 控件的圆角
  double? cornerRadius;

  /// UIButton的背景图片
  String? backgroundImage;

  /// 控件背景颜色
  String? backgroundColor;

  /// 0，文本左对齐。<br>
  /// 1，文本居中显示。<br>
  /// 2文本右对齐
  int? textAlignment;

  /// UILabel显示的文字
  String? text;

  /// UILabel的字体颜色
  String? textColor;

  /// 设置可点击控件的点击事件，在监听中回调。详见事件监听
  String? action;

  /// 自定义控件的相关位置
  FrameModel? frame;

  /// 网易易盾一键登录iOS自定义页面的自定义控件对应模型
  IosWidgetModel({
    this.type,
    this.image,
    this.title,
    this.titleColor,
    this.titleFont,
    this.cornerRadius,
    this.backgroundImage,
    this.backgroundColor,
    this.textAlignment,
    this.text,
    this.textColor,
    this.action,
    this.frame,
  });

  Map<String, dynamic> toJson() {
    Map<String, dynamic> data = <String, dynamic>{};
    if (type != null) {
      data["type"] = type;
    }
    if (image != null) {
      data["image"] = image;
    }
    if (title != null) {
      data["title"] = title;
    }
    if (titleColor != null) {
      data["titleColor"] = titleColor;
    }
    if (titleFont != null) {
      data["titleFont"] = titleFont;
    }
    if (cornerRadius != null) {
      data["cornerRadius"] = cornerRadius;
    }
    if (backgroundImage != null) {
      data["backgroundImage"] = backgroundImage;
    }
    if (textAlignment != null) {
      data["textAlignment"] = textAlignment;
    }
    if (text != null) {
      data["text"] = text;
    }
    if (textColor != null) {
      data["textColor"] = textColor;
    }
    if (action != null) {
      data["action"] = action;
    }
    if (frame != null) {
      data["frame"] = frame!.toJson();
    }
    return data;
  }
}

/// 自定义控件位置
class FrameModel {
  /// 距离屏幕左边的距离，默认为0
  double? mainScreenLeftDistance;

  /// 距离屏幕右边的距离，默认为0
  double? mainScreenRightDistance;

  /// 距离屏幕顶部的距离，默认为0
  double? mainScreenTopDistance;

  /// 为0时，居中显示。<br>
  /// 大于0，向屏幕左侧偏移。<br>
  /// 小于0，向右侧偏移
  double? mainScreenCenterXWithLeftDistance;

  /// 控件的宽度，默认为0
  double? width;

  /// 控件的高度，默认为0
  double? height;

  /// 自定义控件位置
  FrameModel({
    this.mainScreenLeftDistance,
    this.mainScreenRightDistance,
    this.mainScreenTopDistance,
    this.mainScreenCenterXWithLeftDistance,
    this.width,
    this.height,
  });

  Map<String, dynamic> toJson() {
    Map<String, dynamic> data = <String, dynamic>{};
    if (mainScreenLeftDistance != null) {
      data["mainScreenLeftDistance"] = mainScreenLeftDistance;
    }
    if (mainScreenRightDistance != null) {
      data["mainScreenRightDistance"] = mainScreenRightDistance;
    }
    if (mainScreenTopDistance != null) {
      data["mainScreenTopDistance"] = mainScreenTopDistance;
    }
    if (mainScreenCenterXWithLeftDistance != null) {
      data["mainScreenCenterXWithLeftDistance"] =
          mainScreenCenterXWithLeftDistance;
    }
    if (width != null) {
      data["width"] = width;
    }
    if (height != null) {
      data["height"] = height;
    }
    return data;
  }
}
